package com.aistar.service.impl;

import com.aistar.mapper.ClubActivityMapper;
import com.aistar.pojo.ClubActivity;
import com.aistar.pojo.ClubActivityExample;
import com.aistar.pojo.Reward;
import com.aistar.pojo.RewardExample;
import com.aistar.service.ClubListService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Collection;
import java.util.Collections;
import java.util.List;

@Service
@Transactional
public class ClubListServiceImpl implements ClubListService {

    @Autowired
    private ClubActivityMapper clubActivityMapper;
    @Autowired
    private ClubListService clubListService;
    @Override
    public List<ClubActivity> findAll() {
        ClubActivityExample example = new ClubActivityExample();
        ClubActivityExample.Criteria criteria = example.createCriteria();
        criteria.getAllCriteria();
        List<ClubActivity> clubActivityList =clubActivityMapper.selectByExample(example) ;
        Collections.reverse(clubActivityList);
        return clubActivityList;
    }

    @Override
    public PageInfo<ClubActivity> getAll(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<ClubActivity> clubActivities =clubListService.findAll();
        return new PageInfo<ClubActivity>(clubActivities);
    }
}
